package common

import "errors"

const (
	SUCCESS_CODE         = 0
	NOT_FOUND_ERROR_CODE = 100200001
	UNKNOWN_ERROR_CODE   = 100200002
	SERVER_ERROR_CODE    = 100200003
	// Request error codes
	PARAMETER_ERROR_CODE  = 100200004
	AUTH_ERROR_CODE       = 100200005
	NAME_CHECK_ERROR_CODE = 100200006
	// APP error codes
	APP_ERROR_CODE = 100200007

	// error
	ErrUnsupportCmdCode       = 100200100
	ErrModelTooManyCode       = 100200101
	ErrModelEmptyCode         = 100200102
	ErrModelNotCanInferCode   = 100200104
	ErrModelCheckCode         = 100200105
	ErrModelTransformCode     = 100200106
	ErrInitEndpointPolicyCode = 100200107
	ErrModelGetPathCode       = 100200108
	// apedge
	ErrNodeExistCode            = 100201000
	ErrCreateNodeCertCode       = 100201001
	ErrStatusDeleteCode         = 100201002
	ErrNodeNotExistCode         = 100201003
	ErrinvalidNodeArchCode      = 100201004
	ErrCreateInstallScriptsCode = 100201005
	ErrInferExistCode           = 100201006
	ErrInvalidStatusToStopCode  = 100201007
	ErrInvalidStatusToStartCode = 100201008
	ErrNodeServiceNotExistCode  = 100201009
)

var (
	ErrUnsupportCmd = errors.New("err unsupport cmd")
	ErrModelTooMany = errors.New("model is too many")
	ErrModelEmpty   = errors.New("model is empty")

	ErrModelCanNotInfer = errors.New("model can't infer")
	ErrModelCheck       = errors.New("model check error")
	ErrModelTransform   = errors.New("model transform error")
	ErrModelGetPath     = errors.New("model get path error")

	ErrInitEndpointPolicy = errors.New("init endpoint policy error")

	// apedge
	ErrNodeExist            = errors.New("节点已存在 node already exist")
	ErrCreateNodeCert       = errors.New("创建节点证书错误 create node cert err")
	ErrStatusDelete         = errors.New("该状态禁止删除 status not allow to delete")
	ErrNodeNotExist         = errors.New("节点不存在 node not exist")
	ErrinvalidNodeArch      = errors.New("非法节点架构 invalid node arch")
	ErrCreateInstallScripts = errors.New("创建节点安装脚本失败 create node install scripts err")
	ErrInferNameExist       = errors.New("服务名字已存在 infer name already exist")
	ErrInvalidStatusToStop  = errors.New("该状态不可停止 Invalid Status To Stop")
	ErrInvalidStatusToStart = errors.New("该状态不可启动 Invalid Status To Start")
	ErrNodeServiceNotExist  = errors.New("节点服务不存在 node service not exist")
	ErrSvcDeleteStatus      = errors.New("任务不可删除")
)

var ErrorMap = map[error]int{
	ErrUnsupportCmd: ErrUnsupportCmdCode,
	ErrModelTooMany: ErrModelEmptyCode,
	ErrModelEmpty:   ErrModelEmptyCode,

	ErrModelCanNotInfer:   ErrModelNotCanInferCode,
	ErrModelCheck:         ErrModelCheckCode,
	ErrModelTransform:     ErrModelTransformCode,
	ErrInitEndpointPolicy: ErrInitEndpointPolicyCode,
	ErrModelGetPath:       ErrModelGetPathCode,
	// apedge
	ErrNodeExist:            ErrNodeExistCode,
	ErrCreateNodeCert:       ErrCreateNodeCertCode,
	ErrStatusDelete:         ErrStatusDeleteCode,
	ErrNodeNotExist:         ErrNodeNotExistCode,
	ErrinvalidNodeArch:      ErrinvalidNodeArchCode,
	ErrCreateInstallScripts: ErrCreateInstallScriptsCode,
	ErrInferNameExist:       ErrInferExistCode,
	ErrInvalidStatusToStop:  ErrInvalidStatusToStopCode,
	ErrInvalidStatusToStart: ErrInvalidStatusToStartCode,
	ErrNodeServiceNotExist:  ErrNodeServiceNotExistCode,
}
